﻿<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title></title>
    <script src="~/js/frame.js"></script>
</head>
<body>
    <div class="container-fluid">
        <form id="form">
            <div class="formrow">
                <div class="col-xs-12">
                    <div class="formtitle">代码项分组</div>
                    <div class="formcontent">
                        <cloud-tree id="GroupGuid" control-type="selectgroup" select-type="single" grouptag="SystemCode"></cloud-tree>
                    </div>
                </div>
            </div>
            <div class="formrow">
                <div class="col-xs-12">
                    <div class="formtitle required">代码项名称</div>
                    <div class="formcontent">
                        <input name="CodeName" type="text" class="form-control required" placeholder="">
                    </div>
                </div>
            </div>
            <div class="formrow">
                <div class="col-xs-12">
                    <div class="formtitle required">代码项类别</div>
                    <div class="formcontent">
                        <select data-placeholder="选择类别." class="chosen-select form-control required" tabindex="0" name="LevelType">
                            <option value="10">一级代码项</option>
                            <option value="20">多级代码项</option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="formrow">
                <div class="col-xs-12">
                    <div class="formtitle">说明</div>
                    <div class="formcontent">
                        <textarea name="Remark" class="form-control" rows="3" placeholder=""></textarea>
                    </div>
                </div>
            </div>
            <div class="formrow">
                <div class="col-xs-12">
                    <div class="formtitle">排序</div>
                    <div class="formcontent">
                        <input name="SortNum" type="text" class="form-control" placeholder="" value="0">
                    </div>
                </div>
            </div>
            <div style="display:none">
                <input name="CodeGuid" type="text" class="form-control" placeholder="">
            </div>
            <div class="row formbtnop">
                <button class="btn btn-primary cloudbtn" type="button" onclick="Save()"><span class="btntext">保 存</span></button>
                <button class="btn cloudbtn" type="button" onclick="Close()"><span class="btntext">关 闭</span></button>
            </div>
        </form>
    </div>
    <script>
        var validator = $("#form").validate();
        $(function () {
            LoadDetail();
        })
        function LoadDetail() {
            var param = { "CodeGuid": GetUrlParam("codeguid") }
            CloudPost(param, "opdetail", function (res) {
                if (res.code == 0) {
                    $("#form").SetForm(res.data);
                    $("#GroupGuid").attr("selectvalue", res.data.GroupGuid);
                    RenderTree();
                }
            })
        }
        function Save() {
            if (validator.form()) {
                var param = $("#form").GetForm();
                param.GroupGuid = GetTreeSelectValue("GroupGuid")
                CloudPost(param, "opupdate", function (res) {
                    if (res.code == 0) {
                        OpenSuccess("保存成功！", function () {
                            CloseDialog();
                        })
                    } else {
                        OpenFail(res.data)
                    }
                })
            }
        }
        function Close() {
            CloseDialog();
        }
    </script>
</body>
</html>
